package com.snail.controller;

import com.snail.dto.VideoDataVo;
import com.snail.model.pojo.media.BizFiles;
import com.snail.result.Result;
import com.snail.service.BizFilesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Date 2025/8/18 16:41
 * @Author yangming
 * @Description 获取视频的接口
 **/

@RestController
@RequestMapping("/media/files")
public class BizFilesController {

    @Autowired
    private BizFilesService bizFilesService;

    /**
     * 随机获取file_type=0的视频文件
     * @param limit 数量限制，默认10条
     * @return 随机文件列表
     */
    @GetMapping("/random")
    public Result<List<VideoDataVo>> getRandomFiles(
            @RequestParam(defaultValue = "6") Integer limit) {
        List<VideoDataVo> files = bizFilesService.getRandomFilesByType0(limit);
        return Result.success(files);
    }
}
